#include <QtGui/QApplication>
#include <QtGui/QDesktopWidget>
#include <QtDeclarative/QDeclarativeContext>
#include <QtCore/QDebug>

#ifdef Q_WS_MAEMO_5
#include <QtOpenGL/QGLWidget>
#endif

#include <QOrientationSensor>
#include "orientationfilter.h"
QTM_USE_NAMESPACE

#include "qmlapplicationviewer.h"

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    // Create the helper QML-viewer
    QmlApplicationViewer viewer;

    QDeclarativeContext* context = viewer.rootContext();

    viewer.setMainQmlFile(QLatin1String("qml/PlanningPoker/main.qml"));

    // Create an orientation sensor and add it to QML context
    QOrientationSensor sensor;
    OrientationFilter filter;
    sensor.addFilter(&filter);
    sensor.start();
    context->setContextProperty("filter", &filter);

    // For Maemo 5 set some OpenGL params
#ifdef Q_WS_MAEMO_5
    QGLFormat fmt = QGLFormat::defaultFormat();
    fmt.setDirectRendering(true);
    fmt.setDoubleBuffer(true);

    QGLWidget *glWidget = new QGLWidget(fmt);
    viewer.setViewport(glWidget);
    viewer.setOrientation(QmlApplicationViewer::ScreenOrientationLockLandscape);
    viewer.showFullScreen();
#endif


#ifdef Q_OS_SYMBIAN
    viewer.setOrientation(QmlApplicationViewer::ScreenOrientationLockLandscape);
    viewer.showFullScreen();
#endif

    // Start app main-loop
    return app.exec();
}
